package com.yssystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yssystem.domain.Do.SysMenuDO;
import com.yssystem.domain.SysMenu;
import com.yssystem.domain.vo.R;
import com.yssystem.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sysMenu")
@CrossOrigin
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;
    @GetMapping
    public List<SysMenuDO> getList(){
        QueryWrapper<SysMenu> queryWrapper = new QueryWrapper<>();

        List<SysMenuDO> getlist = sysMenuService.getlist(queryWrapper);

//        System.out.println(getlist);
        return getlist;
    }
    //添加
    @PostMapping
    public R addMenu(@RequestBody SysMenu sysMenu){
        return new R(sysMenuService.save(sysMenu),"添加成功",sysMenu,200);
    }
    //删除
    @DeleteMapping("/{id}")
    public R delMenu(@PathVariable Integer id){
        return new R(sysMenuService.removeById(id),"删除成功",200);
    }
    //修改
    @PutMapping
    public R putMenu(@RequestBody SysMenu sysMenu){
        return new R(sysMenuService.updateById(sysMenu),"修改成功",sysMenu,200);
    }

}
